<?

//Data loading
$title='DEBIT NOTE';
$title2='';
if (GetOfficeID()) $perush = GetOfficeLocationForReport (GetOfficeID());
else $perush = 'PT. MASAJI PRAYASA CARGO';

$page   = 'PAGE';
//die();
$DEFINE_FONT=0;
$pdf=new PDFReport("P","mm","Letter");
$pdf->AddPage();
$Result = GridList (GetParam("nobkt",""));
$pdf->GridTable($Result);
$pdf->Output();

function GridList ($TransNo) {
          $Field = ReadHeader($TransNo);
          global $DecimalPoint;
          $DecimalPoint = ($Field->curr<>"IDR")?2:0;
//          print $DecimalPoint;die();
          $DBConnection = new mydb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    //if ($Field->inc_ppn==1)
    //  $SQL = "SELECT *,jumlah*110/100 as jumlah FROM ais_memorial WHERE nobkt='".$TransNo."' AND urut<>999 AND skada <> ".GetPPNSkada()." ORDER BY urut";
    //else
    $SQL = "SELECT * FROM ais_memorial 
            JOIN tbltaxrate as b on ais_memorial.inc_ppn = b.tax_id
            WHERE nobkt='".$TransNo."' AND urut<>999 ORDER BY urut";
  
    
//          die($SQL);
    return $DBConnection->dbc->get_results($SQL,ARRAY_A);
}

function ReadHeader($nokwit) {
        global $DBConnection;

    $SQL = "
      SELECT ais_memorial.*,DATE_FORMAT(depdat,'%d %M, %Y') as spell_date, DATE_FORMAT(tglbkt,'%d %M, %Y') as trans_date, SUM(jumlah)  as TOTALPAID, CUADDR, CUPHONE, CUCODE, DATE_FORMAT(duedate,'%d/%m/%Y') as trans_duedate
      FROM ais_memorial
      LEFT JOIN tbldebtur ON ais_memorial.debtur=tbldebtur.cucode
      WHERE nobkt='$nokwit' GROUP BY nobkt
    ";
    //print $SQL;die();
  return $DBConnection->dbc->get_row($SQL);
}

class PDFReport extends PDF {
        function Header() {
                global $title,$title2,$perush,$page,$DEFINE_FONT,$DBConnection;

                //$this->Ln();$this->Ln();$this->Ln();$this->Ln();$this->Ln();
                if ($DEFINE_FONT==0) {
                        $this->AddFont('Arial','','arialn.php');
                        
                        $DEFINE_FONT=1;
                }
                //$this->SetFont('Arial','',9);
                $Field = ReadHeader(GetParam("nobkt",""));
                $this->spell_date = strtoupper($Field->spell_date);
                $this->trans_date = strtoupper($Field->trans_date);
                list($this->year,$this->month,$this->day) = explode("-",$Field->tglbkt);


                //$this->Image("logomtcon.JPG",10,10,80,15);
                $this->SetFont('Arial','',16);
                $this->Cell(10,7,"",0,0,'L',0);
                $this->Cell(100,7,$perush,0,0,'L',0);
                for ($x=1;$x<=2;$x++)
                {$this->Cell(110,5,"","",0);
                $this->Ln();
                }
                //$this->Cell(100,7,"aaaaaaa",0,0,'C',1);
                $this->Cell(200,20,"",0,1,'L',0);
                $this->Cell(50,7,"",0,0,'L',0);
                $this->SetFont('Arial','',16);
                $this->Cell(100,7,$title,0,0,'C',0);
                $this->SetFont('Arial','',12);
                $this->Cell(200,3,"",0,1,'L',0);
                $this->Ln();$this->Ln();$this->Ln();$this->Ln();
                $this->Ln();
               
                                $this->Cell(10,5," ","",0,'L',0);
                                $this->Cell(110,5," ".$Field->debnam,"LT",0,'L',0);
                                $this->Cell(2,7,"","LR",0,'C',0);
                                $this->Cell(20,7," NUMBER","TB",0,'L',0);
                                $this->Cell(2,7," :","TB",0,'L',0);
                                $this->Cell(50,7,GetParam("nobkt",""),"RTB",0,'L',0);
                                $this->Ln();
                                $this->Cell(10,5," ","",0,'L',0);
                                $this->SetXY(20,63);
                                $this->MultiCell(110,5,trim($Field->CUADDR),"LR","");
                                $this->SetXY(10,63);
                                $this->Cell(10,5,"","R",0,'C',0);
                                $this->Ln();
                                $this->Cell(10,5,"","R",0,'C',0);
                                $this->Ln();
                                $this->Cell(10,5,"","R",0,'C',0);
                                $this->SetXY(130,65);
                                $this->Cell(2,8,"","LR",0,'C',0);
                                $this->Cell(20,8," REFERENCE","B",0,'L',0);
                                $this->Cell(2,8," :","B",0,'L',0);
                                $this->Cell(50,8," ","RB",0,'L',0);
                                $this->Ln();
                                $this->SetXY(20,60);
                                $this->Cell(10,5," ","L",0,'L',0); 
                                $this->SetXY(100,73);
                                $this->Cell(30,5," CODE : ".$Field->debtur,"R",0,'L',0);
                                $this->SetXY(130,73);
                                $this->Cell(2,5,"","LR",0,'C',0);
                                $this->Cell(20,5," CURRENCY","B",0,'L',0);
                                $this->Cell(2,5," :","B",0,'L',0);
                                $this->Cell(50,5,$Field->curr,"RB",0,'L',0);
                                $this->Ln();
                                $this->SetXY(10,78);
                                $this->Cell(10,5," ","",0,'L',0);
                                $this->Cell(110,5,"We Debit Your Account",1,0,'C',0);
                                $this->SetXY(130,78);
                                $this->Cell(2,5,"","LR",0,'C',0);
                                $this->Cell(20,5," DUEDATE","B",0,'L',0);
                                $this->Cell(2,5," :","B",0,'L',0);
                                $this->Cell(50,5,$Field->trans_duedate,"RB",0,'L',0);
                                
                               
                               
                                $this->SetXY(10,87);
                                $this->Cell(10,8," ","",0,'L',0);
                                $this->Cell(10,8,"NO.",1,0,'C',0);
                                $this->Cell(90,8,"DESCRIPTION",1,0,'C',0);
                                $this->Cell(30,8,"AMOUNT",1,0,'C',0);
                                $this->Cell(20,8,"CODE",1,0,'C',0);
                                $this->Cell(24,8,"OFFICE",1,0,'C',0);
                                $this->Cell(10,8,"UU",1,0,'C',0);
                                $this->Ln();
        }

        function GridTable($MyResult) {
            //Column widths
        global $DBConnection,$DBName,$DecimalPoint;

        $DBC1 = new mydb(DB_USER, DB_PASSWORD, OfficeDB1, DB_HOST);
        //$w=array(5,10,80,30,40,20);
        $w=array(10,90,30,20,24,10);
        $iteration = 1;
        $Total = 0;
        $TotalBT = 0;
        $total_tax = 0;
        $package_exist = 0;
            //Data
	    
	    /*
	    echo "<pre>";
	    print_r($MyResult);
	    echo "</pre>";
	    */
	     
        if ($MyResult)
        {
		
            //Count Total befor View
            foreach($MyResult as $row_before_view)
            {
				
				if(!empty($row_before_view["package_services_name"]))
				{
					$package_exist++;
				}
				
				//Tax
				if($row_before_view['tax_kind'] == "exclude")
                {
				   $tax_amount_before_view = $row_before_view['jumlah'] *  $row_before_view['calculate'];
				   $jumlahBT_before_view = $row_before_view['jumlah'];
				   $TotalBT_before_view+= $jumlahBT_before_view;
			    }
			    
			    else if($row_before_view['tax_kind'] == "include")
                {
				   $tax_amount_before_view = 0.1/(1.1 - 0) * $row_before_view['jumlah'];	
				   $jumlahBT_before_view = $row_before_view['jumlah'] - $tax_amount_before_view;
				   $TotalBT_before_view+= $jumlahBT_before_view;
				   
			    }
			    //End Tax
			
				
				$Total_before_view = $Total_before_view + $jumlahBT_before_view + $tax_amount_before_view;
				$total_tax_before_view+= $tax_amount_before_view;
				
				$package_services_name_row = $row_before_view["package_services_name"];
				$skada_row = $row_before_view["skada"];
				$kdact_row = $row_before_view["kdact"];
				$uraian_a_row = $row_before_view["uraian_a"];
				$uraian_b_row = $row_before_view["uraian_b"];
				$uraian_c_row = $row_before_view["uraian_c"];
				$uraian_d_row = $row_before_view["uraian_d"];
				$description_row = $row_before_view["description"];
								        
            }
            //End Count Total befor View
     
           
            if($package_exist > 0)
            {
				//If
				$this->Cell(10,5," ","",0,'L',0);
				$this->Cell($w[0],5,$iteration.".","LR",0,'R',0);
				$this->Cell($w[1],5,$package_services_name_row,"",0,'L',0);
				$this->Cell($w[2],5,FormatNumber($TotalBT_before_view,$DecimalPoint),"R",0,'R',0);
				$this->Cell($w[3],5,$skada_row,"",0,'C',0);
				$this->Cell($w[4],5,"",0,0,'R');
				$this->Cell($w[5],5,$kdact_row,"R",0,'C',0);
				
				$this->Ln();
									
									
				if (strlen($row["uraian_a"])) {
								$brs++;
								$this->Cell(10,5," ","",0,'L',0);
								$this->Cell($w[0],5,"","LR",0,'R',0);
								$this->Cell($w[1],5,"            ".$uraian_a_row,"",0,'L',0);
								$this->Cell($w[2],5,"","R",0,'R',0);
								$this->Cell($w[3],5,"","",0,'C',0);
								$this->Cell($w[4],5,"","",0,'C',0);
								$this->Cell($w[5],5,"","R",0,'R',0);
								$this->Ln();
						}

				if (strlen($row["uraian_b"])) {
								$brs++;
								$this->Cell(10,5," ","",0,'L',0);
								$this->Cell($w[0],5,"","LR",0,'R',0);
								$this->Cell($w[1],5,"            ".$uraian_b_row,"",0,'L',0);
								$this->Cell($w[2],5,"","R",0,'R',0);
								$this->Cell($w[3],5,"","",0,'C',0);
								$this->Cell($w[4],5,"","",0,'C',0);
								$this->Cell($w[5],5,"","R",0,'R',0);
								$this->Ln();
						}

				if (strlen($row["uraian_c"])) {
								$brs++;
								$this->Cell(10,5," ","",0,'L',0);
								$this->Cell($w[0],5,"","LR",0,'R',0);
								$this->Cell($w[1],5,"            ".$uraian_c_row,"",0,'L',0);
								$this->Cell($w[2],5,"","R",0,'R',0);
								$this->Cell($w[3],5,"","",0,'C',0);
								$this->Cell($w[4],5,"","",0,'C',0);
								$this->Cell($w[5],5,"","R",0,'R',0);
								$this->Ln();
						}

				if (strlen($row["uraian_d"])) {
								$brs++;
								$this->Cell(10,5," ","",0,'L',0);
								$this->Cell($w[0],5,"","LR",0,'R',0);
								$this->Cell($w[1],5,"            ".$uraian_d_row,"",0,'L',0);
								$this->Cell($w[2],5,"","R",0,'R',0);
								$this->Cell($w[3],5,"","",0,'C',0);
								$this->Cell($w[4],5,"","",0,'C',0);
								$this->Cell($w[5],5,"","R",0,'R',0);
								$this->Ln();
						}
			   
			   $iteration++; 
			   
			   
			   
			   
				   //Tax
					$this->Cell(10,5," ","",0,'L',0);
					$this->Cell($w[0],5,$iteration.".","LR",0,'R',0);
					$this->Cell($w[1],5,$description_row,"",0,'L',0);
					$this->Cell($w[2],5,FormatNumber($total_tax_before_view,$DecimalPoint),"R",0,'R',0);
					$this->Cell($w[3],5,"","",0,'C',0);
					$this->Cell($w[4],5,"",0,0,'R');
					$this->Cell($w[5],5,"","R",0,'C',0);
					$this->Ln();
					//End Tax
					

				$SQL = "SELECT * FROM ais_memorial WHERE nobkt='".GetParam("nobkt","")."' AND urut=999 ";
				$Field = $DBC1->dbc->get_row($SQL);
			
				$brs++;
						$this->Cell(10,5," ","",0,'L',0);
						$this->Cell($w[0],5,"","LR",0,'R',0);
					$this->Cell($w[1],5,"","",0,'L',0);
					$this->Cell($w[2],5,"","R",0,'R',0);
					$this->Cell($w[3],5,"","",0,'C',0);
					$this->Cell($w[4],5,"","",0,'C',0);
					$this->Cell($w[5],5,"","R",0,'R',0);
					$this->Ln();
					$brs++;
						$this->Cell(10,8," ","",0,'L',0);
					$this->Cell($w[0],8,"999.","LR",0,'R',0);
					//$this->Cell($w[1],8,"",0,0,'R');
					$this->Cell($w[1],8,"TOTAL: ","",0,'R',0);
			if ($Field->curr=="IDR") $Total_before_view = round($Total_before_view);
				$this->Cell($w[2],8,FormatNumber($Total_before_view,$DecimalPoint),"R",0,'R',0);
				$this->Cell($w[3],8,$Field->skada,"",0,'C',0);
						$this->Cell($w[4],5,"","",0,'C',0);
				$this->Cell($w[5],8,$Field->kdact,"R",0,'R',0);
					   $this->Ln();

						$brs = $brs + 2;

					for ($x=1;$x<=2;$x++){
						$this->Cell(10,5," ","",0,'L',0);
					$this->Cell($w[0],5,"","LR",0,'R',0);
					$this->Cell($w[1],5,"","",0,'L',0);
					$this->Cell($w[2],5,"","R",0,'R',0);
					$this->Cell($w[3],5,"","",0,'C',0);
					$this->Cell($w[4],5,"","",0,'C',0);
					$this->Cell($w[5],5,"","R",0,'R',0);
					$this->Ln();
					}

				$cc = new intToRupiah;
				$GetCurrency = $DBC1->dbc->get_var("
				SELECT DISTINCT tunam
				FROM tblcurrency, ais_memorial
				WHERE ais_memorial.nobkt='".GetParam("nobkt","")."' AND
					  tblcurrency.tusymbol=ais_memorial.curr AND
					  ktrasl='".GetOfficeID()."'
				");


					list($number,$decimal) = explode(".",$Total_before_view);

					$cc = new numtoword;
				if ($DecimalPoint<>0)  
				$SpellNumber = strtoupper(trim($cc->en(round($Total_before_view,$DecimalPoint))));		

				else  
				$SpellNumber = strtoupper(trim($cc->en($Total_before_view)));		
				
			$brs++;
						$this->Cell(10,5," ","",0,'L',0);
						$this->Cell($w[0],5,"","LR",0,'R',0);
					$this->Cell($w[1]+$w[2],5,"SAY : ".$SpellNumber." ".$Field->curr,"",0,'L',0);
						$this->Cell($w[3],5,"","L",0,'C',0);
					$this->Cell($w[4],5,"","",0,'C',0);
					$this->Cell($w[5],5,"","R",0,'R',0);
				$this->Ln();
				$brs = $brs + 3;
						for ($x=1;$x<=3;$x++){
				$this->Cell(10,5," ","",0,'L',0);
					$this->Cell($w[0],5,"","LR",0,'R',0);
					$this->Cell($w[1],5,"","",0,'L',0);
					$this->Cell($w[2],5,"","R",0,'R',0);
					$this->Cell($w[3],5,"","",0,'C',0);
					$this->Cell($w[4],5,"","",0,'C',0);
					$this->Cell($w[5],5,"","R",0,'R',0);
					$this->Ln();
				}
			   
			   
			//If	
			}
            
            else
            {
				    //Else          
				    //echo "<pre>"; print_r($MyResult); exit; 
					foreach($MyResult as $row)
					{
						
						
						//Tax
						if($row['tax_kind'] == "exclude")
						{
						   $tax_amount = $row['jumlah'] *  $row['calculate'];
						   $jumlahBT = $row['jumlah'];
						   $TotalBT+= $jumlahBT;
						}
						
						else if($row['tax_kind'] == "include")
						{
						   $tax_amount = 0.1/(1.1 - 0) * $row['jumlah'];	
						   $jumlahBT = $row['jumlah'] - $tax_amount;
						   $TotalBT+= $jumlahBT;
						}
						//End Tax
						
						$Total = $Total + $jumlahBT + $tax_amount;
						$total_tax+= $tax_amount;
						
						
						$brs++;
													
						$this->Cell(10,5," ","",0,'L',0);
						$this->Cell($w[0],5,$iteration.".","LR",0,'R',0);
						$this->Cell($w[1],5,$row["uraian"],"",0,'L',0);
						$this->Cell($w[2],5,FormatNumber($jumlahBT,$DecimalPoint),"R",0,'R',0);
						$this->Cell($w[3],5,$row["skada"],"",0,'C',0);
						$this->Cell($w[4],5,"",0,0,'R');
						$this->Cell($w[5],5,$row["kdact"],"R",0,'C',0);
						
						
						
						$this->Ln();
										
										
						if (strlen($row["uraian_a"])) {
										$brs++;
										$this->Cell(10,5," ","",0,'L',0);
										$this->Cell($w[0],5,"","LR",0,'R',0);
										$this->Cell($w[1],5,"            ".$row["uraian_a"],"",0,'L',0);
										$this->Cell($w[2],5,"","R",0,'R',0);
										$this->Cell($w[3],5,"","",0,'C',0);
										$this->Cell($w[4],5,"","",0,'C',0);
										$this->Cell($w[5],5,"","R",0,'R',0);
										$this->Ln();
								}

						if (strlen($row["uraian_b"])) {
										$brs++;
										$this->Cell(10,5," ","",0,'L',0);
										$this->Cell($w[0],5,"","LR",0,'R',0);
										$this->Cell($w[1],5,"            ".$row["uraian_b"],"",0,'L',0);
										$this->Cell($w[2],5,"","R",0,'R',0);
										$this->Cell($w[3],5,"","",0,'C',0);
										$this->Cell($w[4],5,"","",0,'C',0);
										$this->Cell($w[5],5,"","R",0,'R',0);
										$this->Ln();
								}

						if (strlen($row["uraian_c"])) {
										$brs++;
										$this->Cell(10,5," ","",0,'L',0);
										$this->Cell($w[0],5,"","LR",0,'R',0);
										$this->Cell($w[1],5,"            ".$row["uraian_c"],"",0,'L',0);
										$this->Cell($w[2],5,"","R",0,'R',0);
										$this->Cell($w[3],5,"","",0,'C',0);
										$this->Cell($w[4],5,"","",0,'C',0);
										$this->Cell($w[5],5,"","R",0,'R',0);
										$this->Ln();
								}

						if (strlen($row["uraian_d"])) {
										$brs++;
										$this->Cell(10,5," ","",0,'L',0);
										$this->Cell($w[0],5,"","LR",0,'R',0);
										$this->Cell($w[1],5,"            ".$row["uraian_d"],"",0,'L',0);
										$this->Cell($w[2],5,"","R",0,'R',0);
										$this->Cell($w[3],5,"","",0,'C',0);
										$this->Cell($w[4],5,"","",0,'C',0);
										$this->Cell($w[5],5,"","R",0,'R',0);
										$this->Ln();
								}
					   
					   $iteration++;         
								
					}
				
				
				
				
								
				//Tax
				list($ppn, $type) = explode(" - ", $row["description"]);
				$this->Cell(10,5," ","",0,'L',0);
				$this->Cell($w[0],5,$iteration.".","LR",0,'R',0);
				//$this->Cell($w[1],5,$row["description"],"",0,'L',0);
				$this->Cell($w[1],5,$ppn,"",0,'L',0);
				$this->Cell($w[2],5,FormatNumber($total_tax,$DecimalPoint),"R",0,'R',0);
				$this->Cell($w[3],5,"","",0,'C',0);
				$this->Cell($w[4],5,"",0,0,'R');
				$this->Cell($w[5],5,"","R",0,'C',0);
				$this->Ln();
				//End Tax
				

			$SQL = "SELECT * FROM ais_memorial WHERE nobkt='".GetParam("nobkt","")."' AND urut=999 ";
			$Field = $DBC1->dbc->get_row($SQL);
		
			$brs++;
					$this->Cell(10,5," ","",0,'L',0);
					$this->Cell($w[0],5,"","LR",0,'R',0);
				$this->Cell($w[1],5,"","",0,'L',0);
				$this->Cell($w[2],5,"","R",0,'R',0);
				$this->Cell($w[3],5,"","",0,'C',0);
				$this->Cell($w[4],5,"","",0,'C',0);
				$this->Cell($w[5],5,"","R",0,'R',0);
				$this->Ln();
				$brs++;
					$this->Cell(10,8," ","",0,'L',0);
				$this->Cell($w[0],8,"999.","LR",0,'R',0);
				//$this->Cell($w[1],8,"",0,0,'R');
				$this->Cell($w[1],8,"TOTAL: ","",0,'R',0);
		if ($Field->curr=="IDR") $Total = round($Total);
			$this->Cell($w[2],8,FormatNumber($Total,$DecimalPoint),"R",0,'R',0);
			$this->Cell($w[3],8,$Field->skada,"",0,'C',0);
					$this->Cell($w[4],5,"","",0,'C',0);
			$this->Cell($w[5],8,$Field->kdact,"R",0,'R',0);
				   $this->Ln();

					$brs = $brs + 2;

				for ($x=1;$x<=2;$x++){
					$this->Cell(10,5," ","",0,'L',0);
				$this->Cell($w[0],5,"","LR",0,'R',0);
				$this->Cell($w[1],5,"","",0,'L',0);
				$this->Cell($w[2],5,"","R",0,'R',0);
				$this->Cell($w[3],5,"","",0,'C',0);
				$this->Cell($w[4],5,"","",0,'C',0);
				$this->Cell($w[5],5,"","R",0,'R',0);
				$this->Ln();
				}

			$cc = new intToRupiah;
			$GetCurrency = $DBC1->dbc->get_var("
			SELECT DISTINCT tunam
			FROM tblcurrency, ais_memorial
			WHERE ais_memorial.nobkt='".GetParam("nobkt","")."' AND
				  tblcurrency.tusymbol=ais_memorial.curr AND
				  ktrasl='".GetOfficeID()."'
			");


				list($number,$decimal) = explode(".",$Total);

				$cc = new numtoword;
			if ($DecimalPoint<>0)  
			$SpellNumber = strtoupper(trim($cc->en(round($Total,$DecimalPoint))));		

			else  
			$SpellNumber = strtoupper(trim($cc->en($Total)));		
			
		$brs++;
					$this->Cell(10,5," ","",0,'L',0);
					$this->Cell($w[0],5,"","LR",0,'R',0);
				$this->Cell($w[1]+$w[2],5,"SAY : ".$SpellNumber." ".$Field->curr,"",0,'L',0);
					$this->Cell($w[3],5,"","L",0,'C',0);
				$this->Cell($w[4],5,"","",0,'C',0);
				$this->Cell($w[5],5,"","R",0,'R',0);
			$this->Ln();
			$brs = $brs + 3;
					for ($x=1;$x<=3;$x++){
			$this->Cell(10,5," ","",0,'L',0);
				$this->Cell($w[0],5,"","LR",0,'R',0);
				$this->Cell($w[1],5,"","",0,'L',0);
				$this->Cell($w[2],5,"","R",0,'R',0);
				$this->Cell($w[3],5,"","",0,'C',0);
				$this->Cell($w[4],5,"","",0,'C',0);
				$this->Cell($w[5],5,"","R",0,'R',0);
				$this->Ln();
			}
        
        //Else
        }
        
	}
		
		
        
        //Kata2
        
        $w=array(10,90,30,20,24,10);
        $brs++;
                $this->Cell(10,5," ","",0,'L',0);
                $this->Cell($w[0],5,"","LR",0,'R',0);
                if (strlen($this->spell_date))
                $this->Cell($w[1]+$w[2],5,"    ".GetBranchName().", ".$this->spell_date,"LR",0,'L',0);
           else
                $this->Cell($w[1]+$w[2],5,"    ".GetBranchName().", ".$this->trans_date,"LR",0,'L',0);
            $this->Cell($w[3],5,"","L",0,'C',0);
        $this->Cell($w[4],5,"","",0,'C',0);
            $this->Cell($w[5],5,"","R",0,'R',0);
        $this->Ln();

        $brs=$brs+5;
                for ($x=1;$x<=5;$x++){
                $this->Cell(10,5," ","",0,'L',0);
            $this->Cell($w[0],5,"","LR",0,'R',0);
            $this->Cell($w[1],5,"","",0,'L',0);
            $this->Cell($w[2],5,"","R",0,'R',0);
            $this->Cell($w[3],5,"","",0,'C',0);
            $this->Cell($w[4],5,"","",0,'C',0);
            $this->Cell($w[5],5,"","R",0,'R',0);
            $this->Ln();
            }

        $SQL = "SELECT * FROM $DBName.tblprofile WHERE ktrasl='".GetOfficeID()."'";
        $Result = $DBConnection->dbc->get_row($SQL);
                $brs++;
        $this->Cell(10,5," ","",0,'L',0);
        $this->Cell($w[0],5,"","LR",0,'R',0);
        $this->Cell($w[1]+$w[2],5,"     (".$Result->ttddn.")","LR",0,'L',0);            //treasury
        $this->Cell($w[3],5,"","",0,'C',0);
        $this->Cell($w[4],5,"","",0,'C',0);
        $this->Cell($w[5],5,"","R",0,'R',0);
        $this->Ln();

         for ($x=1;$x<=26-$brs;$x++){
            $this->Cell(10,5," ","",0,'L',0);
            $this->Cell($w[0],5,"","LR",0,'R',0);
            $this->Cell($w[1],5,"","",0,'L',0);
            $this->Cell($w[2],5,"","R",0,'R',0);
            $this->Cell($w[3],5,"","",0,'C',0);
            $this->Cell($w[4],5,"","",0,'C',0);
            $this->Cell($w[5],5,"","R",0,'R',0);
            $this->Ln();
            }
            $this->Cell(10,5," ","",0,'L',0);
            $this->Cell($w[0],5,"","LBR",0,'R',0);
            $this->Cell($w[1],5,"","B",0,'L',0);
            $this->Cell($w[2],5,"","RB",0,'R',0);
            $this->Cell($w[3],5,"","B",0,'C',0);
            $this->Cell($w[4],5,"","B",0,'C',0);
            $this->Cell($w[5],5,"","RB",0,'R',0);
            $this->Ln();$this->Ln();$this->Ln();
            $this->Cell(10,5," ","",0,'L',0);
            $this->MultiCell(100,5,$Result->bankdn);
        }

        function Footer() {
            //Closure line
            //$this->Cell(205,0,'','T');
        }

}


?>
